var api = require('../../../config/api.js');
var util = require('../../../utils/util.js');
var WxParse = require('../../../lib/wxParse/wxParse.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var userInfo=wx.getStorageSync('userInfo');
    if(userInfo!="")
    {
      this.setData({userInfo:userInfo});
      this.getTopic();
    }
    else
    {
      wx.showModal({
        title: '提示',
        content:'请先登录',
        success(res1) 
        {
          wx.navigateTo({url: '/pages/auth/mobile/mobile'})
        }
      })
    }
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  checkboxChange:function(e){
    this.setData({chk:e.detail.value});
  },
  goto_home:function(){
    wx.switchTab({url: '/pages/index/index'})
  },
  hide_desc:function()
  {
    var chk=this.data.chk;
    if(chk.length>0)
    {
      wx.navigateTo({url: '/pages/auth/role/index'});
      
    }
    else
    {
      wx.showModal({title:'提示',content:'同意《会员须知》，才能提交会员信息'});
      return;
    }
  },
  getTopic: function()
  {
       
    let that = this;
     that.setData({
        scrollTop: 0,
        showPage: false,
        topicList: []
    });
    // 页面渲染完成
    wx.showToast({
        title: '加载中...',
        icon: 'loading',
        duration: 2000
    });

  util.request(api.NewsPageList, { SortID:10, IsValid: 1, Page:1, PageSize:1 },'GET').then(function (res) {
    if (res.Status === 100) 
    {
        that.setData({topic: res.Data.Models[0]});
        WxParse.wxParse('topicDetail', 'html', res.Data.Models[0].Contents, that);
      }
      wx.hideToast();
    });
    
  },
})